package com.ytc.teaching.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ytc.commons.model.dto.PageRequest;
import com.ytc.commons.model.vo.CoursePubVo;
import com.ytc.commons.model.vo.PageResponseResult;
import com.ytc.commons.model.vo.ResponseResult;
import com.ytc.teaching.domain.Comment;
import com.ytc.teaching.domain.CourseWorkRec;
import com.ytc.teaching.domain.WorkRecord;
import com.ytc.teaching.mappers.CommentMapper;
import com.ytc.teaching.mappers.TeachWorkRecordMapper;
import com.ytc.teaching.mappers.WorkRecordMapper;
import com.ytc.teaching.service.TeachWorkRecordService;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.List;

@Slf4j
@Service
@RequiredArgsConstructor
public class TeachWorkRecordServiceImpl extends ServiceImpl<TeachWorkRecordMapper, CourseWorkRec> implements TeachWorkRecordService {

    @Autowired
    private WorkRecordMapper workRecordMapper;

    @Override
    public ResponseResult findList(PageRequest request) {

        Integer pageNo = request.getPageNo();
        Integer pageSize = request.getPageSize();
        Page<CourseWorkRec> page = new Page<>(pageNo, pageSize);
        Page<CourseWorkRec> page1 = this.page(page, null);
        return PageResponseResult.okResult(page1.getTotal(),page1.getRecords());
    }

    @Override
    public List<WorkRecord> selectByTeachplanId(Long teachplanId, Integer pageNo, Integer pageSize) {
        LambdaQueryWrapper<WorkRecord> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WorkRecord::getTeachplanId, teachplanId);
        Page<WorkRecord> result = workRecordMapper.selectPage(
                new Page<>(pageNo, pageSize), queryWrapper);
        return result.getRecords();
    }

    @Override
    public WorkRecord findById(Long id) {

        return null;
    }


}
